﻿/*****************************************************************************
 *
 *	WUZEWEN Create on 2005-9-6,高级版用js文件,需要结合开发版的mainbody.js文件使用。
 *
 *****************************************************************************/

var table,table2,tablecols01="",tablecols02="",tablecols03="",tablecols04="", tablecols05="",tablecols06="",tablecols07="";	
var dbType="";				//当前数据库类型
var tblgrid;				//二维数组表示表的列信息，于上面的所有tabl...相同。两种取数方案
var data=new Object();		//***** 第三种数据保存方案，json, data是所有页面数据的root.
var setting = new Object(); // data的属性
var tableMkbh="";			//模块编号
var sqlCommitSign=";" ;		//sql语句提交符号
var file_path ;						//文件保存路径
var clientSidePath ="E:/ProgramXP/pda/";			//delete '/' on 2005-8-25
var fso = null ;					//FileSystemObject
//var companyName="WangWin"; 		//公司名称Kingnor Soft, Sino-Town $("#company").val()

getFSO();

var gd_date = new Date() ;			//当前日期
var gs_year = gd_date.getYear();	//当前年
var gs_date = gs_year + "-" + (gd_date.getMonth()+1) + "-"+gd_date.getDate() ;

/**
 *<p>save individuality setting.
 *	高级版不建议保存，覆盖普通版的保存方法。</p>
 *
 */
function saveSettting(){
	alert("不用保存，在界面即刻起作用！");
}

/**
 *	2005-08-10 web file 格式化,生成格式规范的jsp文件
 */
function formatWebFile(){
	var resutFileName = window.prompt("创建组合Create Table SQL","在此输入要格式化的文件全路经。");
	if(resutFileName==null )
		return ;
	resutFileName=resutFileName.replace(/\\/g,"/") ;
	//alert(resutFileName);
	if(!fso.FileExists(resutFileName)){
		alert("文件不存在！");
		return ;
	}
	var f,ts_ori,ts_result,ts_temp,allCon="";
	var ForReading = 1;
	ts_ori =fso.OpenTextFile(resutFileName,ForReading);
	ts_temp =fso.CreateTextFile(resutFileName+".temp",true);
	while( ts_ori.AtEndOfStream != true ){
		//读取一行
		allCon += ts_ori.ReadLine().trim() + "\n";			
	}
	ts_ori.Close() ;
	allCon = formatWebcode( allCon ).trim()+"\n" ;
	var pos = allCon.indexOf("\n"),posHead=0;
	while(pos>0){
		ts_temp.WriteLine(allCon.substring(posHead,pos));
		posHead = pos+1 ;
		pos = allCon.indexOf("\n",posHead) ;
	}
	ts_temp.Close();
	f = fso.GetFile(resutFileName);
	f.Delete();
	f = fso.GetFile(resutFileName +".temp");
	f.Copy(resutFileName);
	f.Delete();
	alert("file beautifier success!");
}
/**
 *	2005-04-29 web jsp 视图文件格式化,生成格式规范的jsp文件
 */
function formatWebcode( orgStr ){

	var divs = "" ;
	var prevTag = "" ;
	var beginNotHtml = "" ;
	var endNotHtml = "" ;
	var otherTags = "" ;
	var isInBody = false ;						//是否是在html的body(正文)内 (html正文之外的照搬过来)
	//是否是java变量函数定义的代码 这部分代码建议在 body之前,但是如果位于body内了,也必须保存原样照搬过来
	var isJavaDeclare = false ;	
	var isJavaScript = false ;			
	var isJavaCode = false ;
	var isFirstOne = true ;						//第一个tab不用后移一个\t
	var tagsStart = new Array("<table","<tr","<td");
	var tagsEnd   = new Array("</table","</tr","</td");
	var tagsOther = new Array("<html","</html","<head","</head","<body","</body");

	divs = "" ;
	var originalCon 
	if(orgStr==null)
		originalCon = document.all("result_02").value.trim()+"\n" ;
	else
		originalCon = orgStr ;

	var formattedCon = "",rowCon="" ;
	var pos = 0 ;
	if(originalCon=="" || originalCon==null)
		return ;
	headCon = "" ;
	while(pos>=0){
		//fsa<table>  <tr>  <td> fdsf </td> </tr> </table>
		if(originalCon.indexOf("\n",pos+1)<0) break ;
		rowCon = originalCon.substring(pos,originalCon.indexOf("\n",pos+1)) ;

		//alert(pos);
		//alert("0 stage= " + rowCon);
		var posTag =  0 ;

		posTag = indexOfTag(rowCon.trim(),posTag) ;

		// <%! 和 <script 都不会嵌套别的，比较单纯的标签，处理如下 <% 也是照搬
		// 照搬的有：  body 之前 javaDeclare,javaScript;  body 之后的 javaCode
		//set isJavaDeclare
		if( isJavaDeclare==false && rowCon.toLowerCase().indexOf("<%!")>=0 ) isJavaDeclare=true ;
		if( isJavaDeclare==true && rowCon.toLowerCase().indexOf("%>")>=0 ) isJavaDeclare=false ;
		//set isJavaScript
		if( isJavaScript==false && rowCon.toLowerCase().indexOf("<script")>=0 && isInBody==false ) isJavaScript=true ;
		if( isJavaScript==true && rowCon.toLowerCase().trim().endsWith("</script"+">") && isInBody==false ) isJavaScript=false ;
		//set isJavaCode
		if( isJavaCode==false && rowCon.toLowerCase().indexOf("<%")>=0 && rowCon.toLowerCase().indexOf("<%!")<0 ) isJavaCode=true ;
		if( isJavaCode==true && rowCon.toLowerCase().indexOf("%>")>=0) isJavaCode=false ;


		//set isInBody
		if( isJavaScript==false && isInBody==false && (rowCon.toLowerCase().indexOf("<body")>=0||rowCon.toLowerCase().indexOf("<table")>=0) )	isInBody=true ;
		if( isJavaScript==false && isInBody==true && rowCon.toLowerCase().indexOf("</body")>=0 )	isInBody=false ;



		if(isInBody==true){

			if(rowCon.trim()==""){
				pos = originalCon.indexOf("\n",pos+1) ;
				continue;			//对于html中(即"<html>...</html>之间的内容")的空行，全部删除
			}

			// 最好不要连续出现 采用堆栈处理		//rowCon.trim().indexOf("<%!")>=0 || rowCon.trim().indexOf("<%")>=0 
			if(rowCon.trim().indexOf("<script")>=0 || rowCon.trim().indexOf("<!--")>=0 || rowCon.trim().indexOf("/*")>=0){
				beginNotHtml += ";true" ;
				endNotHtml   += ";false" ;
				if(rowCon.trim().indexOf("<script")>=0)
					otherTags += ";script";
				else
					otherTags += ";others";
			}
			if(rowCon.trim().indexOf("</script")>=0 || rowCon.trim().indexOf("-->")>=0 || rowCon.trim().indexOf("%>")>=0 || rowCon.trim().indexOf("*/")>=0){
				endNotHtml = endNotHtml.substring(0,endNotHtml.lastIndexOf(";"))+";true" ;
				otherTags = otherTags.substring(0,otherTags.lastIndexOf(";")) ;
			}
		}

		posTag = indexOfTag(rowCon.trim(),posTag) ;

		//alert("rowCon="+rowCon+"  \nposTage=="+posTag + "   \nposTag>=0"+( eval(""+posTag+">=0") ));
		if(isInBody==false || isJavaDeclare==true || isJavaCode==true){
			//如果没有在 body内,照搬过来就可以了,不丢掉任何一行,其他的情况只处理 body内的
			formattedCon += rowCon ;       // "------isInBody="+isInBody+"isJavaScript"+isJavaScript+"isJavaDeclare"+isJavaDeclare+"\n"+直接按原来的照搬
				
		}else if( (beginNotHtml.endsWith("false")||beginNotHtml=="") && posTag>=0 ){	//
			//如果在 body内,而且有html标签的 html代码处理如下：
			rowCon = rowCon.trim() ;
			posTag = indexOfTag(rowCon,posTag) ;		//trim后重新定位
			var isFirst = true ;
			while(posTag>=0){
				//alert("1 stage= " + rowCon);
				//posTag = indexOfTag(rowCon,posTag) ;
				var headCon = "";
				headCon = rowCon.substring(0,posTag).trim();	//tag前的内容
				var tempPos = indexOfTag(rowCon,posTag+1);
				tempPos = (tempPos<0)?rowCon.length:tempPos;
				var tagCon = rowCon.substring(posTag,tempPos ).trim() ;
				//alert(tagCon);
				var tag = "" ;
				//
				if(posTag>=0){
					tag = rowCon.substr(posTag,4);
				}
				if(posTag>=0){
					//alert("tag="+tag);
					if( prevTag.substr(0,3)==tag.substr(0,1)+tag.substr(2,4) || tag.substr(0,3)==prevTag.substr(0,1)+prevTag.substr(2,4) ){				//</td> 不用前移
					
					}else if( tag.indexOf("/")>0 ) {				//</td> 不用前移
						divs = divs.substring(0,divs.lastIndexOf("\t")) ;
					}else{
						divs += (isFirstOne)?"":"\t" ;
						isFirstOne = false ;
					}
				}
				//为了使第一个<table>不前移,对div的修改放到后面去

				//
				if(headCon!="" && isFirst == true) formattedCon += "\n" + divs + "\t" + headCon ;
				if( (tag.indexOf("/td")>0&&prevTag.substr(0,3)==tag.substr(0,1)+tag.substr(2,4)) || posTag<0)				//</td> 不用前移
					formattedCon += tagCon ;
				else
					formattedCon += "\n" + divs+tagCon ;				


				//alert(formattedCon.substring(3000)); return ;
				prevTag = tag ;
				isFirst = false ;
				if(indexOfTag(rowCon,posTag+1)<0) break ;
				posTag = indexOfTag(rowCon,posTag+1) ;

			}
		}else if( (beginNotHtml.endsWith("false")||beginNotHtml=="") || ( beginNotHtml.endsWith("true")&&otherTags.endsWith("others") ) ){
			// if is innerHtml in tag
			rowCon = rowCon.trim() ;
			if(divs.indexOf("\t")>=0)
				formattedCon +=  "\n" + divs +"\t"+ rowCon ;
			else
				formattedCon +=  "\n" + divs + rowCon ;

		}else{
			//如果没有标签,也不丢掉任何一行
			if(beginNotHtml.endsWith("true") ){ 
				//if is comment or java code
				formattedCon += "\n"+divs+rowCon.trim() ;       //"------->"+beginNotHtml+endNotHtml+"\n"+直接按原来的照搬
				
				if( endNotHtml.endsWith("true") ){
					beginNotHtml = beginNotHtml.substring(0,beginNotHtml.lastIndexOf(";")) ;
					endNotHtml =  endNotHtml.substring(0,endNotHtml.lastIndexOf(";"))  ;
				}
			}
		}

		pos = originalCon.indexOf("\n",pos+1) ;
		
	}
	
	if(orgStr==null){
		document.all.tablecols00.value = formattedCon ;
		Exec( document.all.tablecols00, 'Copy') ;
	}else{
		return formattedCon ;
	}
}


/**
 *	2005-04-29 由 formatWebcode( orgStr )方法调用
 */
function indexOfTag(str,from){
	var tblpos=10000,trpos=10000,tdpos=10000,tblendpos=10000,trendpos=10000,tdendpos=10000;
	tblpos =	(str.indexOf("<table",from)<0)?10000:str.indexOf("<table",from);
	tblendpos = (str.indexOf("</table",from)<0)?10000:str.indexOf("</table",from) ;
	trpos =		(str.indexOf("<tr",from)<0)?10000:str.indexOf("<tr",from) ;
	trendpos =	(str.indexOf("</tr",from)<0)?10000:str.indexOf("</tr",from) ;
	tdpos =		(str.indexOf("<td",from)<0)?10000:str.indexOf("<td",from) ;
	tdendpos =	(str.indexOf("</td",from)<0)?10000:str.indexOf("</td",from) ;
	var pos ;
	pos = Math.min(Math.min(Math.min(tblpos,tblendpos),trpos),trendpos) ;
	pos = Math.min(Math.min(pos,tdpos),tdendpos) ;
	var tag ;
	if (pos==10000)
		pos = -1 ;
	//alert("return pso ="+pos);
	return pos ;		
}

/**
 *	加密
 */
function smp_encode(str)
{
	str='a';
	var htext = ""; // blank text
	for ( var i = 0; i < str.length; i++)
	{
		alert(str.charCodeAt(i))
		htext=String.fromCharCode(""+(str.charCodeAt(i)+1));
	}
	alert(htext)
	str=htext;
	for ( var i = 0; i < str.length; i++)
	{
		htext=String.fromCharCode(""+(str.charCodeAt(i)-1));
	}
	alert(htext)
	return ;
}
/**
 *	解密
 */
function smp_decode(str)
{
	var dtext = ""; 
	for ( var i=0; i < str.Length; i++)
	{
		dtext = dtext + (char) (str[i] - 10 + 1*2);
	}
	return dtext;
}

/**
 *	将字符串转换为 unicode 格式为：  \uxyzw\uedfg...
 *
 *  使用函数：document.write( toUnicode("中文") );
 *	相应的反向处理： alert( unescape("\u4E2D\u6587") );
 *
 */
function toUnicode(){
	var result="";
	var str=document.all.result_02.value;
	if(str==null||str.trim()=="")
		return;
	result=escape(str.trim());
	result=result.replace(/%u/g,"\\u");
	document.all.tablecols00.value=result;
	Exec( document.all.tablecols00, 'Copy') ;
}

/**
 *	将unicode 串变为格式：  \uxyzw\uedfg...
 */
function addSeparatorToUnicodeString(){
	var result="";
	var str=document.all.result_02.value;
	if(str==null||str.trim()=="")
		return;
	while(str.length>=4){
		result+="\\u"+str.substr(0,4);
		str = str.substring(4,str.length);
	}
	//获取剩余部分
	if(str!=""){
		result+="\\u"+str;
	}
	document.all.tablecols00.value=result;
	Exec( document.all.tablecols00, 'Copy') ;
}


/**
 *	file对象中的文件路径转换为folder的路径
 */
function filePahToFolder(obj){
	//alert(obj.value);
	var value = obj.value;
	if(value==null || value.trim()=="")
		return;
	value = value.substring(0,value.lastIndexOf("\\")).replace(/\\/g,"/") + "/";
	obj.value = value ;
	document.getElementById("file_path").value = value ;
}

/**
 *	打开文件夹(资源管理器)
 */
function openfileFolder(){
	window.open(getFile_path(),"","");
}

function htm_body_onLoad(){
	///getFSO();
	var obj = window.event.srcElement ;
	window.status="Copyright (C) 2002-2005 KingCore Software    Programming Developer Assistant    ★数据库、中间件、业务层、显示层、项目文档    eMail:wuzeven@tom.com";
	//获取配置参数
	getSettting();
	//指定焦点获取者
	document.getElementById("table0").focus();
}

/**
 *	创建一个全局的fso对象
 */
function getFSO(){ 
	try{
		if(fso==null){
			fso = new ActiveXObject("Scripting.FileSystemObject"); 
		}
		//fso.GetFile("W:\abc.txt").Delete();
	}catch(e){
		alert(e);
		//document.getElementById("howtodo_div").style.display="block";
	} 
	return fso;
}


/**
 *	WUZEWEN ON 2005-8-8
 *	组合当前目录下的所有建表文件为一个表结构说明文件，类型为 html/doc
 */
function getSystemTableCreateHtml(){

	var tableChTokenizer="",tableNameTokenizer="";
	var h1Id=0,h2Id=0,h3Id=0;
	var createFileType="html" ;
	var colIdWidth=45,colChWidth=150,colEnWidth=120,colTypeWidth=135,colNullWidth=60,colDefaultWidth=60;
	//option:var colIdWidth=55,colChWidth=145,colEnWidth=115,colTypeWidth=130,colNullWidth=75,colDefaultWidth=75;
	if(createFileType=="doc"){
		colIdWidth=30,colChWidth=70,colEnWidth=70,colTypeWidth=110,colNullWidth=30,colDefaultWidth=30;
	}
	//--------------- 读取对象模型，将数据和显示风格分离[未全部]
	var ForWriting=2, ts0 ;
	var fso=getFSO();
	ts0 = fso.CreateTextFile( document.all.file_path.value+"/allTableCreate.html", true);
	var f1, ts,l_str; 
	var ForReading = 1; 
	//读取 xxx.html(.doc) 的模板
	try{
		ts = fso.OpenTextFile( clientSidePath+"model_AllTableCreateDoc.html" , ForReading);	//确保当前路径为本文件路径
		//alert(clientSidePath+"model_AllTableCreateDoc.html");
		//return;
	}catch(exp){
		alert("找不到模板文件:"+clientSidePath+"model_AllTableCreateDoc.html" 
					+ "\n\t请将/pda/jsp下面的model_AllTableCreateDoc.html文件拷贝过去再执行!");
		ts0.close();
		return;
	}
	var contentHead="",contentTail="" ;
	//读取首部并写入
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		l_str = l_str.trim() ;
		ts0.WriteLine(l_str);
		if(l_str=="<!-- ModelBegin -->")
			break ; 
	}

ts0.WriteLine("<h2 style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo3;");
ts0.WriteLine("tab-stops:list 21.0pt'><![if !supportLists]><span lang=EN-US style='font-family:");
ts0.WriteLine("宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>"+ ++h2Id +"、<span");
ts0.WriteLine("style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]><span");
ts0.WriteLine("style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>数据库表结构说明</span></h2>");

//ts0.WriteLine("<h2 style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:21.0pt;") ;
//ts0.WriteLine("margin-bottom:.0001pt;text-indent:-21.0pt;line-height:normal;mso-list:l1 level1 lfo4;") ;
//ts0.WriteLine("tab-stops:list 21.0pt'><a name=\"_Toc108495707\"><![if !supportLists]><span") ;
//ts0.WriteLine("lang=EN-US>1.<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") ;
//ts0.WriteLine("</span></span><![endif]><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
//ts0.WriteLine("mso-hansi-font-family:\"Times New Roman\"'>"+"数据库表结构说明"+"</span></a></h2>") ;

	//用户变化的数据区	
	var folderPath = document.all.file_path.value ;
	var fldr = fso.GetFolder( folderPath ); 
	// 处理文件夹
		// todo...
	// 处理文件
	var fc = new Enumerator(fldr.files);
	var fileName = "";
	var tableId = 0 ;
	for (var i_2=0; !fc.atEnd(); fc.moveNext(),i_2++)
	{
		//获取文件名     
		fileName = fc.item() ;  
		fileName += "" ;
		if( !(fileName.trim().endsWith(".woo.table")) || fileName.trim().indexOf("_H__")>0 )
			continue ;
		//下面是针对生成报表的表结构详细设计做的过滤  -temp
		//if( fileName.trim().indexOf("FX_BB_BBCSXX")>0 || fileName.trim().indexOf("FX_BB_SJZDXX")>0 || fileName.trim().indexOf("FX_BB_")<0)
		//	continue ;

		//创建新的文件对象并且读取  rowCon 不使用 trim()函数
		var f1, ts,l_str, rowCon="";
		var outPos=-1 ;
		var ForReading = 1;
		ts3 = fso.OpenTextFile( fileName, ForReading); 
	
		//通过 ts3读取文件内容如下：
		//定位
		var tableEn=fileName.substring(0,fileName.indexOf("___")),tableCh="";
		var colType="",colEn="",colCh="",colNull="";
		while( ts3.AtEndOfStream != true ){
			l_str = ts3.ReadLine();
			l_str = l_str.trim() ;
			if( l_str.indexOf("表名")>0 ){
				tableCh = l_str.substring( l_str.indexOf("表名:")+3,l_str.indexOf("*/") );
			}else if( l_str.indexOf("Table Name:")>0 ){
				tableCh = l_str.substring( l_str.indexOf("Table Name:")+11,l_str.indexOf("*/") );
			}
			//if( l_str.indexOf("]")>0 ){
			//	document.all.tableMkbh.value = l_str.substring( l_str.indexOf("[")+1, l_str.indexOf("]表名") );
			//}
			if(l_str=="(")
				break ;
		}
//写表头名称和标题行
var tableName="demotable" ;
tableName = tableEn.substring(fileName.lastIndexOf("\\")+1,fileName.indexOf("___"));
tableChTokenizer += tableCh +";";
tableNameTokenizer += tableName +";";
ts0.WriteLine("<h3 style='margin-top:0cm;margin-right:0cm;margin-bottom:0cm;margin-left:21.0pt;") ;
ts0.WriteLine("margin-bottom:.0001pt;text-indent:-21.0pt;line-height:normal;mso-list:l1 level1 lfo4;") ;
ts0.WriteLine("tab-stops:list 21.0pt'><a name=\"_Toc108495707\"><![if !supportLists]><span") ;
ts0.WriteLine("lang=EN-US>"+ h2Id+"."+ ++h3Id +".<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") ;
ts0.WriteLine("</span></span><![endif]><span style='font-size:12.0pt;mso-bidi-font-size:16.0pt;font-family:宋体;mso-ascii-font-family:\"Times New Roman\";mso-hansi-font-family:\"Times New Roman\"'>"+tableCh+"("+tableName+")</span></a></h3>") ;



//ts0.WriteLine("<h3 style='margin-left:90.0pt;text-indent:-81.0pt;mso-list:l0 level4 lfo1;");
//ts0.WriteLine("tab-stops:36.0pt'><![if !supportLists]><span lang=EN-US>1.<span");
//ts0.WriteLine("style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
//ts0.WriteLine("</span></span><![endif]><span lang=EN-US>2222222222</span></h3>");

ts0.WriteLine("<table border=1 cellspacing=0 cellpadding=0 width=\"\" style='") ;
ts0.WriteLine("border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;") ;
ts0.WriteLine("mso-padding-alt:0cm 5.4pt 0cm 5.4pt'>") ;
ts0.WriteLine("<thead>") ;
	ts0.WriteLine("\t<tr style=\"background:silver;\">") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colIdWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tpadding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>序号</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colChWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>中文名及含义</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colEnWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>字段名</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colTypeWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>类型全类型</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colNullWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>可空否</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colDefaultWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>缺省值</span></p></td>") ;
	ts0.WriteLine("\t</tr>") ;
	ts0.WriteLine("\t</thead>") ;	//表头标题行重复

		
		//循环写具体内容
		var i=0,j=0,note="",colNote="" ;
		var colId = 0 ;
		while( ts3.AtEndOfStream != true ){
			l_str = ts3.ReadLine();
			l_str = l_str.trim() ;
			if(l_str==")")
				break ;
			//2005-8-12 替换前获取column's colNote
			if(l_str.indexOf("[")>0){
				colNote = l_str.substring(l_str.indexOf("!")+1,l_str.indexOf("]"));
				l_str = l_str.substring(0,l_str.indexOf("[")) + l_str.substring(l_str.indexOf("]")+1);
			}else{
				colNote = "" ;
			}

			//l_str = l_str.replace(/,/g,"\t") ;			//替换 , 符号
			l_str = l_str.replace(/\t\t\t\t\t/g,"%");			//替换
			l_str = l_str.replace(/,\t\t\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t\t\t/g,"%");			//替换
			l_str = l_str.replace(/,\t\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t\t/g,"%");			//替换 ,\t\t || \t\t\t 符号
			l_str = l_str.replace(/,\t\t/g,"%");
			
			l_str = l_str.replace(/\t\t/g,"%");			//替换 \t\t 符号
			l_str = l_str.replace(/,\t/g,"%");	
			
			l_str = l_str.replace(/\t/g,"%") ;			//替换 \t 符号
			
			i=0 ;
			j = l_str.indexOf("%",0);   
			if(j==0){	// wzw on 2009-9-26
				i=1;
				j=l_str.indexOf("%",1); 
			}
			//alert(l_str);
			//alert(j);
			tablecols01 += l_str.substring(i,j) +"\n" ;
			colEn = l_str.substring(i,j) +"\n" ; 
			//alert(colEn); return ;

			i = ++j ;
			j = l_str.indexOf("%",i);
			tablecols02 += l_str.substring(i,j) +"\n" ;
			colType = l_str.substring(i,j) +"\n" ;
			
			i = ++j ;
			j = l_str.indexOf("%",i);
			tablecols05 += l_str.substring(i,j) +"\n" ;
			colNull= l_str.substring(i,j) +"\n" ;

			i = ++j ;
			j = l_str.indexOf("%",i);
			if(j<0) j = l_str.length ;
			var note = l_str.substring(i,j) ;	/* note */
			note = note.substring(3, note.length-3).trim();
			if(note.indexOf("uncheck")>0){
				tablecols04 += "\n" ;
				tablecols03 += note.substring(0, note.indexOf("uncheck")-1 ) + "\n" ;
				colCh = note.substring(0, note.indexOf("uncheck")-1 ) ;
			}else if( note.indexOf("check")>0 ){
				tablecols04 += note.substring(0, note.indexOf("check")-1 ) + "\n" ;
				tablecols03 += note.substring(0, note.indexOf("check")-1 ) + "\n" ;
				colCh = note.substring(0, note.indexOf("check")-1 ) ;
			}
			if(colNote!=""){
				colCh +="<br>"+colNote;
			}

	ts0.WriteLine("\t<tr>") ;
		ts0.WriteLine("<td valign=top style='width:"+colIdWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("border-top:none;mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+ ++colId +"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colChWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("mso-hansi-font-family:\"Times New Roman\"'>"+colCh+"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colEnWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+colEn.trim()+"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colTypeWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+colType.trim()+"<span style='color:#0000F0'></span></span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colNullWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+colNull.trim()+"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colDefaultWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US></span></p></td>") ;
	ts0.WriteLine("</tr>") ;

		}

		//循环写索引等信息
		while( ts3.AtEndOfStream != true ){
			l_str = l_str.trim() ;
			if(l_str.indexOf("foreign key")>0 || l_str.indexOf("primary key")>0 || (l_str.indexOf("unique index")>0)||(l_str.indexOf("create index")>=0)||(l_str.indexOf("bitmap index")>=0)||(l_str.indexOf("create unique nonclustered index")>=0)){
				ts0.WriteLine("<tr>") ;
					ts0.WriteLine("<td colspan=6 valign=top style='border:solid windowtext .5pt;") ;
						ts0.WriteLine("border-top:none;mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
						ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+l_str+"</span></p></td>") ;
				ts0.WriteLine("</tr>") ;			}


			l_str = ts3.ReadLine();
		}
		ts3.Close() ;

		ts0.WriteLine("</table>") ;		
		ts0.WriteLine("<p class=MsoNormal><span style='mso-bookmark:_Toc108495707'><span lang=EN-US><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></span></p>") ;	//表间空一行
	}

//alert(++h2Id);
// 在生成完每个表的信息之后，生成一个总的“数据库对象说明”信息的列表
colIdWidth=30,colChWidth=80,colEnWidth=60,colTypeWidth=70,colNullWidth=200,colDefaultWidth=30;
//aption:colIdWidth=55,colChWidth=100,colEnWidth=120,colTypeWidth=120,colNullWidth=200,colDefaultWidth=30;

ts0.WriteLine("<h2 style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo3;");
ts0.WriteLine("tab-stops:list 21.0pt'><![if !supportLists]><span lang=EN-US style='font-family:");
ts0.WriteLine("宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>"+ ++h2Id +"、<span");
ts0.WriteLine("style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]><span");
ts0.WriteLine("style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>数据库对象说明</span></h2>");

//ts0.WriteLine("<h2 style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo1;");
//ts0.WriteLine("tab-stops:list 21.0pt'><![if !supportLists]><span lang=EN-US style='font-family:");
//ts0.WriteLine("黑体;mso-ascii-font-family:Arial'>二、<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
//ts0.WriteLine("</span></span><![endif]><span lang=EN-US>"+"数据库对象说明"+"</span></h2>");

ts0.WriteLine("<table border=1 cellspacing=0 cellpadding=0 width=\"\" style='") ;
ts0.WriteLine("border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;") ;
ts0.WriteLine("mso-padding-alt:0cm 5.4pt 0cm 5.4pt'>") ;
ts0.WriteLine("<thead>") ;
	ts0.WriteLine("\t<tr style=\"background:silver;\">") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colIdWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tpadding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>序号</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colChWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>对象名</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colEnWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>对象类型</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colTypeWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>相关库表</span></p></td>") ;
		ts0.WriteLine("\t\t<td align=center valign=top style='width:"+colNullWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("\t\t\tborder-left:none;mso-border-left-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("\t\t\t<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("\t\t\tmso-hansi-font-family:\"Times New Roman\"'>对象说明</span></p></td>") ;
	ts0.WriteLine("\t</tr>") ;
	ts0.WriteLine("\t</thead>") ;	//表头标题行重复

var posOri = 0,pos=0 ;
tableId = 0 ;
var tableEnArray = new Array();
tableEnArray = tableNameTokenizer.split(";");
while(tableChTokenizer.indexOf(";",posOri)>0 ){
	pos = tableChTokenizer.indexOf(";",posOri)
	tableCh = tableChTokenizer.substring(posOri,pos );
	posOri = pos+1 ;

	tableEn = tableEnArray[tableId] ;
	if(tableCh.endsWith("表")){
		tableCh = tableCh.substring(0,tableCh.length-1);
	}
	ts0.WriteLine("\t<tr>") ;
		ts0.WriteLine("<td valign=top style='width:"+colIdWidth+"px;border:solid windowtext .5pt;") ;
			ts0.WriteLine("border-top:none;mso-border-top-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+ ++tableId +"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colChWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span style='font-family:宋体;mso-ascii-font-family:\"Times New Roman\";") ;
			ts0.WriteLine("mso-hansi-font-family:\"Times New Roman\"'>"+tableEn+"</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colEnWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>Table</span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colTypeWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+""+"<span style='color:#0000F0'></span></span></p></td>") ;
		ts0.WriteLine("<td valign=top style='width:"+colNullWidth+"px;border-top:none;border-left:") ;
			ts0.WriteLine("none;border-bottom:solid windowtext .5pt;border-right:solid windowtext .5pt;") ;
			ts0.WriteLine("mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;") ;
			ts0.WriteLine("padding:0cm 5.4pt 0cm 5.4pt'>") ;
			ts0.WriteLine("<p class=MsoNormal><span lang=EN-US>"+tableCh+"</span></p></td>") ;
	ts0.WriteLine("</tr>") ;
}

ts0.WriteLine("</table>") ;		
ts0.WriteLine("<p class=MsoNormal><span style='mso-bookmark:_Toc108495707'><span lang=EN-US><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></span></p>") ;	//表间空一行


	//去中间 temp
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		if(l_str=="<!-- ModelEnd -->"){			
			ts0.WriteLine(l_str);
			break ; 
		}
	}
	//读取尾部
	while( ts.AtEndOfStream != true ){
		l_str = ts.ReadLine();
		l_str = l_str.trim() ;
		ts0.WriteLine(l_str);
	}
	ts.close();
	//---------------
	//alert(contentHead);
	//alert(contentTail);	
	ts0.Close() ;
	alert("生成文件成功！");
}

/**
 * <p>生成用户的所有表的建表sql文件。</p>
 * @author WUZEWEN on 2005-8-6
 * @param hasNote 是否带有列和表的注释，用于保密
 * @return 无。
 */
function getSystemTableCreate(hasNote){
	if(hasNote==null)
		hasNote=true;
	var folderPath , resutFileName="", resutFile ;
	folderPath = document.all.file_path.value ;
	if(folderPath==null || folderPath==""){
		alert("请填写要组合的文件的路径！");
		document.all.file_path.focus() ;
		return ;
	}
	//resutFileName = window.prompt("创建组合Create Table SQL","在此输入生成的组合文件的名称。");
	if(resutFileName==null||resutFileName=="")
		resutFileName="allTableCreate";
	if(hasNote==false)
		resutFileName="allTableCreateNoComment";
	if(resutFileName.trim()=="") 
		return ;
	resutFileName = folderPath + resutFileName + ".sql" ;	//建议sql文件打开设置 tab=4

	// 创建FileSystemObject对象实例 
	var fldr,fc ;
	var fileName ; 
	fldr = fso.GetFolder( folderPath ); 
	resutFile = fso.CreateTextFile( resutFileName, true);
	
	// 处理文件夹
		// todo...
	// 处理文件
	fc = new Enumerator(fldr.files);
	//fc.sort();	//有没有别的排序的方法？
	fileName = "";
	resutFile.WriteLine("-- allTableCreate.sql");
	resutFile.WriteLine("-- creat by " + window.document.title+",WUZEWEN on " + gs_date ) ;
	resutFile.WriteLine("");
	for (var i=0; !fc.atEnd(); fc.moveNext(),i++)
	{
		//获取文件名     
		fileName = fc.item() ;  
		fileName += "" ;
		if( !(fileName.trim().endsWith(".woo.table")))
			continue ;
		//创建新的文件对象并且读取  rowCon 不使用 trim()函数
		var f1, ts,l_str, rowCon="";
		var outPos=-1 ;
		var ForReading = 1;
		ts = fso.OpenTextFile( fileName, ForReading); 
		while( ts.AtEndOfStream != true ){
			//读文件，写入新文件中
			rowCon = ts.ReadLine();
			if(hasNote==false){		//不要注释
				if(rowCon.indexOf("/*")>-1){	//是否要所有说明部分
					rowCon=rowCon.substring(0,rowCon.indexOf("/*"));
				}
				if(rowCon.indexOf("comment on")>-1){	//是否要comment部分
					break;
				}
			}
			resutFile.WriteLine( rowCon ) ;					
		}
		ts.Close() ;
		resutFile.WriteLine("") ; 
	}

	resutFile.Close() ;
	alert("生成文件成功！");
}


/**
 *	WUZEWEN on 2005-8-11
 *	组合当前目录下的所有表文件 woo.table 中的关于添加 comment的statement 到  allTableComment.sql 中。
 */
function getAllTableCommentSQL(){
	var folderPath , resutFileName=null, resutFile ;
	folderPath = document.all.file_path.value ;
	alert("--------1");
	if(folderPath==null || folderPath==""){
		alert("请填写要组合的文件的路径！");
		document.all.file_path.focus() ;
		return ;
	}
	alert("--------2");
	//resutFileName = window.prompt("创建组合Create Table SQL","在此输入生成的组合文件的名称。");
	if(resutFileName==null)	resutFileName="allTableComment";
	alert("--------31")
	if(resutFileName.trim()=="") return ;
	alert("--------32")
	resutFileName = folderPath + resutFileName + ".sql" ;	//建议sql文件打开设置 tab=4

	// 创建FileSystemObject对象实例 
	var fldr,fc ;
	var fileName ;
	var tableId=0;
	alert("--------3");
	fldr = fso.GetFolder( folderPath ); 
	alert("--------4");
	resutFile = fso.CreateTextFile( resutFileName, true);
	
	// 处理子目录
		// todo...
	// 处理文件
	fc = new Enumerator(fldr.files);
	fileName = "";
	resutFile.WriteLine("-- allTableComment.sql");
	resutFile.WriteLine("-- creat by " + window.document.title+",WUZEWEN on " + gs_date ) ;
	resutFile.WriteLine("");
	for (var i=0; !fc.atEnd(); fc.moveNext(),i++)
	{
		//获取文件名     
		fileName = fc.item() ;  
		fileName += "" ;
		if( !(fileName.trim().endsWith(".woo.table")))
			continue ;
		//创建新的文件对象并且读取  rowCon 不使用 trim()函数
		var f1, ts,l_str, rowCon="";
		var outPos=-1 ;
		var ForReading = 1;
		ts = fso.OpenTextFile( fileName, ForReading); 
		resutFile.WriteLine("-- "+ ++tableId +". "+fileName.substring(fileName.lastIndexOf("\\")+1,fileName.indexOf(".woo.table")).replace("___","  "));
		while( ts.AtEndOfStream != true ){
			//读文件，写入新文件中(自动判断数据库是 oracle 还是 sqlserver)
			rowCon = ts.ReadLine();
			if(rowCon.indexOf("comment on table")>-1 ||
			   rowCon.indexOf("comment on column")>-1){
				if(rowCon.lastIndexOf("'")-rowCon.indexOf("'")>1 &&
				   rowCon.indexOf("'XX表'")<0){				//务必确保所有comment内容中不能有'号
					resutFile.WriteLine( rowCon ) ;
				}
			}else if(rowCon.indexOf("exec sp_addextendedproperty 'MS_Description'")>-1){
				var pos = rowCon.indexOf("'MS_Description'")+16;
				if(rowCon.indexOf("'",pos+4)-rowCon.indexOf("'",pos+2)>1){	//务必确保所有comment内容中不能有'号
					resutFile.WriteLine( rowCon ) ;
				}
			}			
		}
		ts.Close() ;
		resutFile.WriteLine("") ; 
	}
	resutFile.Close() ;
	alert("生成文件成功！");
}

/**
 *	WUZEWEN on 2005-8-11
 *	组合当前目录下的所有表文件 woo.table 中的关于添加 comment的statement 到  allTableNoComment.sql 中。
 *	目的是去掉所有comment信息，用于正式库的保密作用。
 */
function getAllTableNoCommentSQL(){
	var folderPath , resutFileName=null, resutFile ;
	folderPath = document.all.file_path.value ;
	if(folderPath==null || folderPath==""){
		alert("请填写要组合的文件的路径！");
		document.all.file_path.focus() ;
		return ;
	}
	//resutFileName = window.prompt("创建组合Create Table SQL","在此输入生成的组合文件的名称。");
	if(resutFileName==null)	resutFileName="allTableNoComment";
	if(resutFileName.trim()=="") return ;
	resutFileName = folderPath + resutFileName + ".sql" ;	//建议sql文件打开设置 tab=4

	// 创建FileSystemObject对象实例 
	var fldr,fc ;
	var fileName ;
	var tableId=0;
	fldr = fso.GetFolder( folderPath ); 
	resutFile = fso.CreateTextFile( resutFileName, true);
	
	// 处理子目录
		// todo...
	// 处理文件
	fc = new Enumerator(fldr.files);
	fileName = "";
	resutFile.WriteLine("-- allTableNoComment.sql");
	resutFile.WriteLine("-- creat by " + window.document.title+",WUZEWEN on " + gs_date ) ;
	resutFile.WriteLine("");
	for (var i=0; !fc.atEnd(); fc.moveNext(),i++)
	{
		//获取文件名     
		fileName = fc.item() ;  
		fileName += "" ;
		if( !(fileName.trim().endsWith(".woo.table")))
			continue ;
		//创建新的文件对象并且读取  rowCon 不使用 trim()函数
		var f1, ts,l_str, rowCon="";
		var outPos=-1 ;
		var ForReading = 1;
		ts = fso.OpenTextFile( fileName, ForReading); 
		resutFile.WriteLine("-- "+ ++tableId +". "+fileName.substring(fileName.lastIndexOf("\\")+1,fileName.indexOf(".woo.table")).replace("___","  "));
		while( ts.AtEndOfStream != true ){
			//读文件，写入新文件中(自动判断数据库是 oracle 还是 sqlserver)
			rowCon = ts.ReadLine();
			if(rowCon.indexOf("comment on table")>-1 ||
			   rowCon.indexOf("comment on column")>-1){
				//对所有的列赋空注释，而不是只对有注释的列
				resutFile.WriteLine(rowCon.substring(0,rowCon.indexOf("'")+1)+rowCon.substr(rowCon.lastIndexOf("'"))) ;
			}else if(rowCon.indexOf("exec sp_addextendedproperty 'MS_Description'")>-1){
				var pos = rowCon.indexOf("'MS_Description'")+16;
				if(rowCon.indexOf("'",pos+4)-rowCon.indexOf("'",pos+2)>1){	//务必确保所有comment内容中不能有'号
					resutFile.WriteLine(rowCon.substring(0,rowCon.indexOf("'")+1)+rowCon.substr(rowCon.lastIndexOf("'"))) ;
				}
			}			
		}
		ts.Close() ;
		resutFile.WriteLine("") ; 
	}
	resutFile.Close() ;
	alert("生成文件成功！");
}
